package com.e3roid.examples;

import android.widget.Toast;

import com.e3roid.E3Activity;
import com.e3roid.E3Engine;
import com.e3roid.E3Scene;
import com.e3roid.util.FPSListener;
import com.e3roid.util.Debug;

public class FPSListenerExample extends E3Activity implements FPSListener {

	private final static int WIDTH  = 320;
	private final static int HEIGHT = 480;
	
	@Override
	public E3Engine onLoadEngine() {
		E3Engine engine = new E3Engine(this, WIDTH, HEIGHT);
		engine.requestFullScreen();
		engine.requestPortrait();
		engine.getFPSCounter().addListener(this);
		return engine;
	}

	@Override
	public E3Scene onLoadScene() {
		E3Scene scene = new E3Scene();		
		Toast.makeText(this, 
				"Current FPS is logging into debug log.",
				Toast.LENGTH_LONG).show();
		return scene;
	}

	@Override
	public void onLoadResources() {
		Debug.d("onLoadResource");
	}

	@Override
	public void onFPS(float fps, float min, float max) {
		Debug.d(String.format("FPS: %.2f (MIN %.2f / MAX %.2f)", fps, min, max));
	}

}